﻿using MainApplication.DataEntry;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace MainApplication.DataContext
{
    public class TeachDbContext : DbContext
    {
        // 学生表
        public DbSet<Student> Students { get; set; }
        
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            // 可选：使用Fluent API进行更详细的配置
            modelBuilder.Entity<Student>(entity =>
            {
            
                entity.Property(s => s.Name).IsRequired().HasMaxLength(50);
                entity.Property(s => s.Gender).IsRequired().HasMaxLength(10);
                entity.Property(s => s.Gender);
            });
        }
    }
}
